package aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class LogAspect {
	private final String pointcut="execution(* service.WorkService.work(..))";
	@Before(value=pointcut)
	public void logBefore(){
		System.out.println("log before....");
	}
	@After(value=pointcut)
	public void logAfter(){
		System.out.println("log after....");
	}
	
	@Around(value=pointcut)
	public Object logArround(ProceedingJoinPoint point){
		System.out.println("arround before.....");
		Object o=null;
		String t=(String)point.getArgs()[0];
		try {
			
			point.proceed();
		} catch (Throwable e) {
			e.printStackTrace();
		}
		System.out.println("arround after.....");
		return "nihuai:"+t;
	}
}
